<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Boot WMS</title> 
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css"> 
  <!-- Ionicons -->
  <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"> 
 
 
   <!-- jsGrid -->
  <link rel="stylesheet" href="plugins/jsgrid/jsgrid.min.css">
  <link rel="stylesheet" href="plugins/jsgrid/jsgrid-theme.min.css">
  
  
  <!-- jquery-ui -->
  <link rel="stylesheet" href="plugins/jquery-ui/jquery-ui.min.css">
 
  <!-- Tempusdominus Bbootstrap 4 -->
  <link rel="stylesheet" href="plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css">
  <!-- iCheck -->
  <link rel="stylesheet" href="plugins/icheck-bootstrap/icheck-bootstrap.min.css">
  <!-- JQVMap -->
  <link rel="stylesheet" href="plugins/jqvmap/jqvmap.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/adminlte.min.css">
  <!-- overlayScrollbars -->
  <link rel="stylesheet" href="plugins/overlayScrollbars/css/OverlayScrollbars.min.css">
  <!-- Daterange picker -->
  <link rel="stylesheet" href="plugins/daterangepicker/daterangepicker.css">
  <!-- summernote -->
  <link rel="stylesheet" href="plugins/summernote/summernote-bs4.css"> 
  <!-- Google Font: Source Sans Pro -->
  <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
</head>
<!-- jQuery -->
<script src="plugins/jquery/jquery.min.js"></script>
<script src="plugins/jquery-ui/jquery-ui.min.js"></script>
<body class="hold-transition sidebar-mini layout-fixed">
<div class="wrapper">

  <!-- Navbar -->
  <nav class="main-header navbar navbar-expand navbar-white navbar-light">  
	<div id="test1"></div> 
	<div id="test2"></div>
    
    <ul class="navbar-nav ml-auto"> 
		<div id="test3"></div> 
		<div id="test4"></div>
		<li class="nav-item">
		  <a class="nav-link" data-widget="control-sidebar" data-slide="true" href="#">
		    <i class="fas fa-th-large"></i>
		  </a>
		</li>
    </ul>
  </nav>
  <!-- /.navbar -->

  <aside class="main-sidebar sidebar-dark-primary elevation-4">
  	<div id="logo1"></div> 
    <div class="sidebar">
		<div id="user1"></div>
		<nav class="mt-2">
			 <ul class="nav nav-pills nav-sidebar flex-column" 
			 	 data-widget="treeview" 
			 	 role="menu" 
			 	 data-accordion="false">
			 	<div id="menu1"></div> 
		 	 </ul>
		</nav>
  	</div> 
  </aside>  

  
  <div class="content-wrapper">
  	<!-- 主区域标题 -->
    <section class="content-header">
   
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-9">
	          <h1 class="m-0 text-dark">
   				商品信息维护2
	          </h1>
          </div>
          
          <div class="col-sm-1"> 
          	<button type="button" 
          		    class="btn btn-block btn-primary"
          		    data-toggle="modal"
          		    data-target="#modal-addNewSKU1">
          		新增
          	</button>
          </div>
          
          <div class="col-sm-2"> 
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="./index.html">主页</a></li>
              <li class="breadcrumb-item active">货物信息</li>
            </ol>
          </div>
        </div>
        
      </div>
      
    </section>
    
    
    <section class="content">
      <div class="card">    
        <div class="card-header">
          <h3 class="card-title">货物品名的数据列表</h3>
        </div>     
        
      	<div class="card-body">
    		<div id="jsGrid1"></div>
    	</div>
    	
      </div>
    </section>
    
    
  </div>
 

<div class="modal fade" id="modal-addNewSKU1">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title">
        	确认删除
        </h4>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body"> 
	    <p>新增窗口</p>
	    <hr/> 
  		<div class="card-body">
       	  <form action="" name="post_form" id="post_form" role="form">
 			<div class="row">
				<div class="col-sm-3">
  					<div class="form-group">
	  					<label>物料编码</label>
						<input type="text" id="skuId" name="skuId" 
							class="form-control" placeholder="">
  					</div>
				</div>
				<div class="col-sm-3">
  					<div class="form-group">
  						<label>货主名称</label>
						<input type="text" id="storekey" name="storekey" 
							class="form-control" placeholder="">
  					</div>
				</div> 
				<div class="col-sm-3">
  					<div class="form-group">
	  					<label>法定数量</label>
						<input type="text" id="skuNum" name="skuNum" 
							class="form-control" placeholder="">
  					</div>
				</div>
				<div class="col-sm-3">
  					<div class="form-group">
  						<label>中文名</label>
						<input type="text"  id="skuCN" name="skuCN" 
							class="form-control" placeholder="">
  					</div>
				</div> 
			</div>
 			<div class="row">
				<div class="col-sm-3">
  					<div class="form-group">
	  					<label>英文名</label>
						<input type="text" id="skuEN" name="skuEN" 
							class="form-control" placeholder="">
  					</div>
				</div>
				<div class="col-sm-3">
  					<div class="form-group">
  						<label>法定单位</label>
						<input type="text"  id="legalUnit" name="legalUnit" 
							class="form-control" placeholder="">
  					</div>
				</div> 
				<div class="col-sm-3">
  					<div class="form-group">
	  					<label>最小存储数量</label>
						<input type="text" id="moq" name="moq" 
							class="form-control" placeholder="">
  					</div>
				</div>
				<div class="col-sm-3">
  					<div class="form-group">
  						<label>库位占位数量</label>
						<input type="text"  id="skuVolNum" name="skuVolNum" 
							class="form-control" placeholder="">
  					</div>
				</div>  
			</div>
 			<div class="row">
				<div class="col-sm-3">
  					<div class="form-group">
	  					<label>备注1</label>
						<input type="text" id="remark1" name="remark1" 
							class="form-control" placeholder="">
  					</div>
				</div>
				<div class="col-sm-3">
  					<div class="form-group">
  						<label>备注2</label>
						<input type="text"  id="remark2" name="remark2" 
							class="form-control" placeholder="">
  					</div>
				</div> 
				<div class="col-sm-3">
  					<div class="form-group">
	  					<label>备注3</label>
						<input type="text" id="remark3" name="remark3" 
							class="form-control" placeholder="">
  					</div>
				</div>
				<div class="col-sm-3">
  					<div class="form-group">
  						<label>备注4</label>
						<input type="text"  id="remark4" name="remark4" 
							class="form-control" placeholder="">
  					</div>
				</div>  
			</div>
 			<div class="row">
				<div class="col-sm-6">
  					<div class="form-group">
	  					<label>备注5</label>
						<input type="text" id="remark5" name="remark5" 
							class="form-control" placeholder="">
  					</div>
				</div>
				<div class="col-sm-6">
  					<div class="form-group">
  						<label>备注6</label>
						<input type="text"  id="remark6" name="remark6" 
							class="form-control" placeholder="">
  					</div>
				</div>  
			</div>
		  </form>
        </div>
      </div>
      <div class="modal-footer justify-content-between">
        <button type="button" class="btn btn-default" data-dismiss="modal">
        	关闭
        </button>
        <button type="button" onclick="confirmedAdd()" data-dismiss="modal" 
        	class="btn btn-primary">确认添加</button>
      </div>
    </div>
    <!-- /.modal-content -->
  </div>
  <!-- /.modal-dialog -->
</div>
<!-- /.modal -->  



<div class="modal fade" id="modal-updateSKU1">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title">
        	确认删除
        </h4>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body"> 
	    <p>新增窗口</p>
	    <hr/> 
  		<div class="card-body">
       	  <form action="" name="post_form" id="post_form" role="form">
 			<div class="row">
				<div class="col-sm-3">
  					<div class="form-group">
	  					<label>物料编码</label>
						<input type="text" id="skuId" name="skuId" 
							class="form-control" placeholder="">
  					</div>
				</div>
				<div class="col-sm-3">
  					<div class="form-group">
  						<label>货主名称</label>
						<input type="text" id="storekey" name="storekey" 
							class="form-control" placeholder="">
  					</div>
				</div> 
				<div class="col-sm-3">
  					<div class="form-group">
	  					<label>法定数量</label>
						<input type="text" id="skuNum" name="skuNum" 
							class="form-control" placeholder="">
  					</div>
				</div>
				<div class="col-sm-3">
  					<div class="form-group">
  						<label>中文名</label>
						<input type="text"  id="skuCN" name="skuCN" 
							class="form-control" placeholder="">
  					</div>
				</div> 
			</div>
 			<div class="row">
				<div class="col-sm-3">
  					<div class="form-group">
	  					<label>英文名</label>
						<input type="text" id="skuEN" name="skuEN" 
							class="form-control" placeholder="">
  					</div>
				</div>
				<div class="col-sm-3">
  					<div class="form-group">
  						<label>法定单位</label>
						<input type="text"  id="legalUnit" name="legalUnit" 
							class="form-control" placeholder="">
  					</div>
				</div> 
				<div class="col-sm-3">
  					<div class="form-group">
	  					<label>最小存储数量</label>
						<input type="text" id="moq" name="moq" 
							class="form-control" placeholder="">
  					</div>
				</div>
				<div class="col-sm-3">
  					<div class="form-group">
  						<label>库位占位数量</label>
						<input type="text"  id="skuVolNum" name="skuVolNum" 
							class="form-control" placeholder="">
  					</div>
				</div>  
			</div>
 			<div class="row">
				<div class="col-sm-3">
  					<div class="form-group">
	  					<label>备注1</label>
						<input type="text" id="remark1" name="remark1" 
							class="form-control" placeholder="">
  					</div>
				</div>
				<div class="col-sm-3">
  					<div class="form-group">
  						<label>备注2</label>
						<input type="text"  id="remark2" name="remark2" 
							class="form-control" placeholder="">
  					</div>
				</div> 
				<div class="col-sm-3">
  					<div class="form-group">
	  					<label>备注3</label>
						<input type="text" id="remark3" name="remark3" 
							class="form-control" placeholder="">
  					</div>
				</div>
				<div class="col-sm-3">
  					<div class="form-group">
  						<label>备注4</label>
						<input type="text"  id="remark4" name="remark4" 
							class="form-control" placeholder="">
  					</div>
				</div>  
			</div>
 			<div class="row">
				<div class="col-sm-3">
  					<div class="form-group">
	  					<label>备注5</label>
						<input type="text" id="remark5" name="remark5" 
							class="form-control" placeholder="">
  					</div>
				</div>
				<div class="col-sm-3">
  					<div class="form-group">
  						<label>备注6</label>
						<input type="text"  id="remark6" name="remark6" 
							class="form-control" placeholder="">
  					</div>
				</div>  
				<div class="col-sm-3">
  					<div class="form-group">
	  					<label>编号</label>
						<input type="text" id="id" name="id" readonly
							class="form-control" placeholder="">
  					</div>
				</div>
				<div class="col-sm-3">
  					<div class="form-group">
  						<label>创建日期</label>
						<input type="text" id="createDate" name="createDate" readonly
							class="form-control" placeholder="">
  					</div>
				</div>  
			</div>
		  </form>
        </div>
      </div>
      <div class="modal-footer justify-content-between">
        <button type="button" class="btn btn-default" data-dismiss="modal">
        	关闭
        </button>
        <button type="button" onclick="confirmedEdit()" data-dismiss="modal" 
        	class="btn btn-primary">确认修改</button>
      </div>
    </div>
    <!-- /.modal-content -->
  </div>
  <!-- /.modal-dialog -->
</div>
<!-- /.modal -->  


<div class="modal fade" id="modal-deleteSKU1">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title">
        	确认删除
        </h4>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <p>
        	是否要删除编号为: &nbsp; <span id="idNo"></span> &nbsp; 的SKU
        </p>
      </div>
      <div class="modal-footer justify-content-between">
        <button type="button" class="btn btn-default" data-dismiss="modal">
        	关闭
        </button>
        <button type="button" onclick="confirmedDel()" data-dismiss="modal" 
        	class="btn btn-primary">确认删除</button>
      </div>
    </div>
    <!-- /.modal-content -->
  </div>
  <!-- /.modal-dialog -->
</div>
<!-- /.modal -->


  
<div id="footer"></div>
  
<!-- jQuery -->
<script src="plugins/jquery/jquery.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="plugins/jquery-ui/jquery-ui.min.js"></script>
<!-- Bootstrap 4 -->
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="plugins/jsgrid/jsgrid.min.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
</body>
<script type="text/javascript">

	var gid = 0;

function timestampToString(timestamp) {
    // 创建一个新的 Date 对象，使用传入的时间戳（注意：JavaScript 的 Date 对象期望的是毫秒）
    const date = new Date(timestamp);

    // 获取各个部分
    const year = date.getFullYear();
    const month = String(date.getMonth() + 1).padStart(2, '0'); // getMonth() 返回值是 0-11
    const day = String(date.getDate()).padStart(2, '0');
    const hours = String(date.getHours()).padStart(2, '0');
    const minutes = String(date.getMinutes()).padStart(2, '0');
    const seconds = String(date.getSeconds()).padStart(2, '0');

    // 格式化输出
    return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
  
	
	(function($){
		console.log("start");
		localStorage.setItem("menuId", 1);
		//$("#mainHeader").load("mainHeader1.html");
		$("#test1").load("test1.html");
		$("#test2").load("test2.html");
		$("#test3").load("test3.html");
		$("#test4").load("test4.html");
		$("#logo1").load("logo1.html");
		$("#user1").load("user1.html");
		$("#menu1").load("menu1.html");
		$("#footer").load("foot.html");
	
		initialData();
		iniTableData();
	})(jQuery);

	function confirmedDel(){
		console.log("confirmedDel()",gid)
		
		var data1 = {"id":gid};
		
		var url1 = '../api/baseInfo/cmn/deleteSKU'
		
		$.ajax({
			url: url1,
			type: "POST",
			data: data1,
			success: function(res){
				console.log("删除提交成功")
			}
		})
		
		setTimeout(()=> {
			iniTableData();
		},555)
		
	}
	
	function confirmedAdd(){
		console.log("confirmedAdd()")
		
	    var formData = $('#modal-addNewSKU1 #post_form').serialize();
		console.log("formData-=>",formData)

		$.ajax({
		    url: "../api/baseInfo/cmn/addNewSKU",
		    type: "POST",
		    data: formData,
		    success: function(response) {
		        console.log("SKU新增-提交成功");
		    }
		});
		
		setTimeout(()=> {
			iniTableData();
		},555)
		
	}
	
	function confirmedEdit(){
		console.log("confirmedEdit()")
	    var formData = $('#modal-updateSKU1 #post_form').serialize();
		console.log("formData-=>",formData)
		
		var url1 = '../api/baseInfo/cmn/updateSKU'
		
		$.ajax({
			url: url1,
			type: "POST",
			data: formData,
			success: function(res){
				console.log("修改提交成功")
			}
		})
		
		setTimeout(()=> {
			iniTableData();
		},555)
	}
	
	function iniTableData(){
		console.log("iniTableData()")
		
		var data1 = {};
		var url1 = '../api/baseInfo/cmn/listSKU';
		
		$.ajax({
			type: "post",
			url: url1,
			dataType: "json",
			data: data1,
			success: function (res) {
				console.log("iniTableData-=>",res);

				$("#jsGrid1").jsGrid({
			        height: "510px",
			        width: "100%",
			        paging: true,
	                pageSize: 10, 
			        data: res,
			        rowDoubleClick: function(args){
			        	
			        },
			        fields: [
			            { name: "id", type: "number", width: 35, title: '编号' },
			            { name: "skuEN", type: "text", width: 200, title: '英文名' },
			            { name: "skuCN", type: "text", width: 250, title: '中文名' },
			            { name: "skuId", type: "text", width: 65, title: '货物编号' },
			            { name: "skuNum", type: "number", width: 35, title: '数量' },
			            { name: "storekey", type: "text", width: 55, title: '货主' },
			            { name: "skuVolNum", type: "number", width: 50, title: '体积' },
			            { name: "legalUnit", type: "text", width: 35, title: '单位' },
			            { name: "createDate", type: "text", width: 100, title: '创建时间', 
			            	editButton: false,
			            	itemTemplate: function(value, item) {
			            		//return new Date(value).toDateString();
			            		return timestampToString(value)
			            	}
			            },
			            { name: "moq", type: "number", width: 65, title: '包里数量' },
			            {
	                        type: "control",
	                        width: 65,
	                        modeSwitchButton: false,
	                        editButton: false,
	                        deleteButton: false,
	                        itemTemplate: function(value, item) {
	                            return $("<button>").attr("type", "button").text("编辑")
		                    		.addClass("btn btn-block btn-defaul")
	                                .on("click", function (e) {
	                                    showDetailsDialog1("upd", {}, value, item);
	                                });
	                        }
	                    },
			            {
	                        type: "control",
	                        width: 65,
	                        modeSwitchButton: false,
	                        editButton: false,
	                        deleteButton: false,
	                        itemTemplate: function(value, item) {
	                            return $("<button>").attr("type", "button").text("删除")
		                    		.addClass("btn btn-block btn-defaul")
	                                .on("click", function (e) {
	                                    showDetailsDialog1("del", {}, value, item);
	                                });
	                        }
	                    }
			        ]
			    });
			},
			error: function () {
				alert("后台访问错误，请联系管理员！");
			}
		}); 
		
		
		var clients = [
			{
				"Name":"DDD",
				"Age":11,
				"Address":"fadsfa",
				"Country":"AAA",
				"Married":true,
			}
		]
		
		var countries =[
			{
				"Id":"1",
				"Name":"aaa"
			}
		]
		
	}
	
	function showDetailsDialog1(a,b,c,d){
		console.log("showDetailsDialog1-=>",a,b,c,d)
		gid = d.id
		if(a=="upd"){
			$('#modal-updateSKU1').modal('show');
			
			$("#modal-updateSKU1 #id").val(d.id);
			$("#modal-updateSKU1 #createDate").val(timestampToString(d.createDate));
			$("#modal-updateSKU1 #legalUnit").val(d.legalUnit);
			$("#modal-updateSKU1 #moq").val(d.moq);
			$("#modal-updateSKU1 #remark1").val(d.remark1);
			$("#modal-updateSKU1 #remark2").val(d.remark2);
			$("#modal-updateSKU1 #remark3").val(d.remark3);
			$("#modal-updateSKU1 #remark4").val(d.remark4);
			$("#modal-updateSKU1 #remark5").val(d.remark5);
			$("#modal-updateSKU1 #remark6").val(d.remark6);
			$("#modal-updateSKU1 #skuCN").val(d.skuCN);
			$("#modal-updateSKU1 #skuEN").val(d.skuEN);
			$("#modal-updateSKU1 #skuId").val(d.skuId);
			$("#modal-updateSKU1 #skuNum").val(d.skuNum);
			$("#modal-updateSKU1 #skuVolNum").val(d.skuVolNum);
			$("#modal-updateSKU1 #storekey").val(d.storekey);
			
		}else if(a=="del"){
			
			$('#modal-deleteSKU1').modal('show');
			
			$("#modal-deleteSKU1 #idNo").text(d.id);
			
		}
		
	}
	
	function initialData(){
		

		$("#menu1").ready(function(){ 
			console.log("initialData 商品信息维护2 changeActive2222");

		});
		
		setTimeout(function () { 
			console.log("initialData 商品信息维护2 changeActive3333");
			changeMenuActive(2);
        },1000);
	}
	

	$("#menu1").ready(function(){ 
		console.log("initialData changeActive");
		//$("#test1_abc1").html("abc");
		//changeActive(1);
	});
	
	$("#menu1").on('ready',function(){
		console.log("initialData test1_abc1"); 
		//changeActive(1);
	});
	
</script>
</html>